TOSTRING(
#version 330 core \n
#pragma optimize(on) \n

#define TEX_COMBINE_REPLACE			0 \n
#define TEX_COMBINE_MODULATE		1 \n
#define TEX_COMBINE_ADD				2 \n
#define TEX_COMBINE_ADD_SIGNED		3 \n
#define TEX_COMBINE_SUBTRACT		4 \n
#define TEX_REPLACE_ALPHA			5 \n

layout(location = 0, index = 0) out vec4	outColor;

uniform sampler2D	unColorTexture;

layout (std140)
uniform unMaterial {
	float	fAlphaRef;
	int		iCombineMode;
	bool	bAlphaTest;
} Param;


in	TGeomData {
	vec4	vColor;
	vec2	vTexcoord;
} Input;


void main()
{
	/* Combine */
	if ( Param.iCombineMode == TEX_COMBINE_REPLACE )
		outColor = texture( unColorTexture, Input.vTexcoord );
	else
	if ( Param.iCombineMode == TEX_COMBINE_MODULATE )
		outColor = texture( unColorTexture, Input.vTexcoord ) * Input.vColor;
	else
	if ( Param.iCombineMode == TEX_COMBINE_ADD )
		outColor = texture( unColorTexture, Input.vTexcoord ) + Input.vColor;
	else
	if ( Param.iCombineMode == TEX_COMBINE_ADD_SIGNED )
		outColor = texture( unColorTexture, Input.vTexcoord ) + Input.vColor - 0.5;
	else
	if ( Param.iCombineMode == TEX_COMBINE_SUBTRACT )
		outColor = texture( unColorTexture, Input.vTexcoord ) - Input.vColor;
	else
	if ( Param.iCombineMode == TEX_REPLACE_ALPHA ) {
		outColor	= Input.vColor;
		outColor.a	= texture( unColorTexture, Input.vTexcoord ).a;
	}
	else
		outColor = Input.vColor;

	/* Alpha test */
	if ( Param.bAlphaTest && outColor.a <= Param.fAlphaRef )
		discard;
}
)